package net.atomarrow.bean;

import java.io.File;
/**
 * 上传文件
 * @author mmm Michael
 *
 */
public class UploadFile {
	private String parameterName;//上传form参数名
	private String saveDirectory;//保存位置
	private String uploadPath;//相对位置
	//absoluteFilePath;//文件绝对地址
	//requestFilePath;//文件请求相对地址
	private String fileName;//保存后的文件名
	private String originalFileName;//原始文件名
	private String contentType;//文件类型
	
	public UploadFile(String parameterName, String saveDirectory,String uploadPath,String filesystemName, String originalFileName, String contentType) {
		this.parameterName = parameterName;
		this.uploadPath=uploadPath;
		this.saveDirectory = saveDirectory;
		this.fileName = filesystemName;
		this.originalFileName = originalFileName;
		this.contentType = contentType;
	}
	
	public String getParameterName() {
		return parameterName;
	}
	
	public String getFileName() {
		return fileName;
	}
	
	public String getOriginalFileName() {
		return originalFileName;
	}
	
	public String getContentType() {
		return contentType;
	}
	
	public String getSaveDirectory() {
		return saveDirectory;
	}
	
	public String getFilePath(){
	    return saveDirectory + File.separatorChar + fileName;
	}
	public File getFile() {
		if (saveDirectory == null || fileName == null) {
			return null;
		} else {
			return new File(getFilePath());
		}
	}

    public String getUploadPath() {
        return uploadPath;
    }

    public void setUploadPath(String uploadPath) {
        this.uploadPath = uploadPath;
    }

    public String getAbsoluteFilePath() {
        if(!saveDirectory.endsWith("/")){
            saveDirectory=saveDirectory+"/";
          }
        return saveDirectory+fileName;
    }

    public String getRequestFilePath() {
        if(!uploadPath.endsWith("/")){
            uploadPath=uploadPath+"/";
        }
        return uploadPath+fileName;
    }

    public void setSaveDirectory(String saveDirectory) {
        this.saveDirectory = saveDirectory;
    }
    
    
}
